/*
 * SelectScreen.java
 *
 * Created on Aug 31, 2011, 10:54:13 AM
 */
package battleship_client.screens;

import battleship_client.Controller;
import java.awt.*;
import javax.swing.*;

/**
 *
 * @author omar
 */
public class SelectScreen extends Screen {

    /**
     * Crea un objeto SelectScreen
     * @param wh el Window Handler de esta ventana
     */
    public SelectScreen(Controller wh) {
        windowHandler = wh;
        setLookAndFeel();
        initComponents();
    }

    private SelectScreen() {
        initComponents();
    }

    /**
     * Inicializa componentes del objeto SelectScreen
     */
    private void initComponents() {
        setTitle("Position your battleships");
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        setSize(720, 520);
        setResizable(false);
        setLocationRelativeTo(null);

        contentPane = getContentPane();
        mainPanel = new JPanel();
        lblImagen = new JLabel();
        lblPositionShip = new JLabel();
        lbl6SizeShip = new JLabel();
        txt6X = new JTextField();
        lbl6X = new JLabel();
        txt6Y = new JTextField();
        lbl6Y = new JLabel();
        check6Vertical = new JCheckBox();
        lbl5SizeShip = new JLabel();
        lbl5X = new JLabel();
        txt5X = new JTextField();
        lbl5Y = new JLabel();
        txt5Y = new JTextField();
        check5Vertical = new JCheckBox();
        lbl4SizeShip = new JLabel();
        lbl4X = new JLabel();
        txt4X = new JTextField();
        lbl4Y = new JLabel();
        txt4Y = new JTextField();
        check4Vertical = new JCheckBox();
        lbl3SizeShip = new JLabel();
        lbl3X = new JLabel();
        txt3X = new JTextField();
        lbl3Y = new JLabel();
        txt3Y = new JTextField();
        check3Vertical = new JCheckBox();
        lbl2SizeShip = new JLabel();
        lbl2X = new JLabel();
        txt2X = new JTextField();
        lbl2Y = new JLabel();
        txt2Y = new JTextField();
        check2Vertical = new JCheckBox();
        btnReady = new JButton();
        setLblError(new JLabel());

        mainPanel.setLayout(null);
        lblImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/side.png")));
        lblPositionShip.setFont(new java.awt.Font("Lucida Grande", 1, 18));
        lblPositionShip.setText("Please position your battleships");
        lbl6SizeShip.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        lbl6SizeShip.setText("Size 6 Ship:");
        lbl6X.setText("X:");
        getTxt6X().setText("1");
        lbl6Y.setText("Y:");
        getTxt6Y().setText("1");
        check6Vertical.setText("Vertical");
        lbl5SizeShip.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        lbl5SizeShip.setText("Size 5 Ship:");
        lbl5X.setText("X:");
        getTxt5X().setText("1");
        lbl5Y.setText("Y:");
        getTxt5Y().setText("2");
        check5Vertical.setText("Vertical");
        lbl4SizeShip.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        lbl4SizeShip.setText("Size 4 Ship:");
        lbl4X.setText("X:");
        getTxt4X().setText("1");
        lbl4Y.setText("Y:");
        getTxt4Y().setText("3");
        check4Vertical.setText("Vertical");
        lbl3SizeShip.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        lbl3SizeShip.setText("Size 3 Ship:");
        lbl3X.setText("X:");
        getTxt3X().setText("1");
        lbl3Y.setText("Y:");
        getTxt3Y().setText("4");
        check3Vertical.setText("Vertical");
        lbl2SizeShip.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        lbl2SizeShip.setText("Size 2 Ship:");
        lbl2X.setText("X:");
        getTxt2X().setText("1");
        lbl2Y.setText("Y:");
        getTxt2Y().setText("5");
        check2Vertical.setText("Vertical");
        btnReady.setText("Ready!");
        btnReady.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {
                validateSelection();
            }
        });


        lblImagen.setBounds(360, 0, 360, 520);
        lblPositionShip.setBounds(40, 10, 300, 20);
        lbl6SizeShip.setBounds(20, 50, 300, 15);
        lbl6X.setBounds(55, 77, 20, 20);
        lbl6Y.setBounds(140, 77, 20, 20);
        txt6X.setBounds(80, 72, 40, 30);
        txt6Y.setBounds(160, 72, 40, 30);
        lbl5SizeShip.setBounds(20, 130, 300, 15);
        lbl5X.setBounds(55, 157, 20, 20);
        lbl5Y.setBounds(140, 157, 20, 20);
        txt5X.setBounds(80, 152, 40, 30);
        txt5Y.setBounds(160, 152, 40, 30);
        lbl4SizeShip.setBounds(20, 210, 300, 15);
        lbl4X.setBounds(55, 237, 20, 20);
        lbl4Y.setBounds(140, 237, 20, 20);
        txt4X.setBounds(80, 232, 40, 30);
        txt4Y.setBounds(160, 232, 40, 30);
        lbl3SizeShip.setBounds(20, 290, 300, 15);
        lbl3X.setBounds(55, 317, 20, 20);
        lbl3Y.setBounds(140, 317, 20, 20);
        txt3X.setBounds(80, 312, 40, 30);
        txt3Y.setBounds(160, 312, 40, 30);
        lbl2SizeShip.setBounds(20, 370, 300, 15);
        lbl2X.setBounds(55, 397, 20, 20);
        lbl2Y.setBounds(140, 397, 20, 20);
        txt2X.setBounds(80, 392, 40, 30);
        txt2Y.setBounds(160, 392, 40, 30);
        btnReady.setBounds(130, 440, 100, 30);
        check2Vertical.setBounds(220, 397, 100, 20);
        check3Vertical.setBounds(220, 317, 100, 20);
        check4Vertical.setBounds(220, 237, 100, 20);
        check5Vertical.setBounds(220, 157, 100, 20);
        check6Vertical.setBounds(220, 77, 100, 20);
        getLblError().setBounds(50, 425, 4000, 20);
        getLblError().setVisible(false);

        mainPanel.add(lblImagen);
        mainPanel.add(lblPositionShip);
        mainPanel.add(lbl6SizeShip);
        mainPanel.add(lbl6X);
        mainPanel.add(lbl6Y);
        mainPanel.add(txt6X);
        mainPanel.add(txt6Y);
        mainPanel.add(check6Vertical);
        mainPanel.add(lbl5SizeShip);
        mainPanel.add(lbl5X);
        mainPanel.add(lbl5Y);
        mainPanel.add(txt5X);
        mainPanel.add(txt5Y);
        mainPanel.add(lbl4SizeShip);
        mainPanel.add(lbl4X);
        mainPanel.add(lbl4Y);
        mainPanel.add(txt4X);
        mainPanel.add(txt4Y);
        mainPanel.add(lbl3SizeShip);
        mainPanel.add(lbl3X);
        mainPanel.add(lbl3Y);
        mainPanel.add(txt3X);
        mainPanel.add(txt3Y);
        mainPanel.add(lbl2SizeShip);
        mainPanel.add(lbl2X);
        mainPanel.add(lbl2Y);
        mainPanel.add(txt2X);
        mainPanel.add(txt2Y);
        mainPanel.add(getLblError());
        mainPanel.add(btnReady);
        mainPanel.add(check2Vertical);
        mainPanel.add(check3Vertical);
        mainPanel.add(check4Vertical);
        mainPanel.add(check5Vertical);
        contentPane.add(mainPanel);
    }

    private void validateSelection() {
        windowHandler.validator.validateSelection(this);
    }
    private Controller windowHandler;
    private JButton btnReady;
    private JCheckBox check6Vertical;
    private JCheckBox check5Vertical;
    private JCheckBox check4Vertical;
    private JCheckBox check3Vertical;
    private JCheckBox check2Vertical;
    private JLabel lblPositionShip;
    private JLabel lblImagen;
    private JLabel lbl6SizeShip;
    private JLabel lbl6X;
    private JLabel lbl6Y;
    private JLabel lbl5SizeShip;
    private JLabel lbl5X;
    private JLabel lbl5Y;
    private JLabel lbl4SizeShip;
    private JLabel lbl4X;
    private JLabel lbl4Y;
    private JLabel lbl3SizeShip;
    private JLabel lbl3X;
    private JLabel lbl3Y;
    private JLabel lbl2SizeShip;
    private JLabel lbl2X;
    private JLabel lbl2Y;
    private JLabel lblError;
    private JPanel mainPanel;
    private JTextField txt6X;
    private JTextField txt6Y;
    private JTextField txt5X;
    private JTextField txt5Y;
    private JTextField txt4X;
    private JTextField txt4Y;
    private JTextField txt3X;
    private JTextField txt3Y;
    private JTextField txt2X;
    private JTextField txt2Y;
    private Container contentPane;

    /**
     * Checks if check6Vertical is selected
     * @return
     */
    public boolean isCheck6Selected() {
        return check6Vertical.isSelected();
    }

    /**
     * Checks if check5Vertical is selected
     * @return
     */
    public boolean isCheck5Selected() {
        return check5Vertical.isSelected();
    }

    /**
     * Checks if check4Vertical is selected
     * @return
     */
    public boolean isCheck4Selected() {
        return check4Vertical.isSelected();
    }

    /**
     * Checks if check3Vertical is selected
     * @return
     */
    public boolean isCheck3Selected() {
        return check3Vertical.isSelected();
    }

    /**
     * Checks if check2Vertical is selected
     * @return
     */
    public boolean isCheck2Selected() {
        return check2Vertical.isSelected();
    }

    /**
     * @return the txt6X
     */
    public JTextField getTxt6X() {
        return txt6X;
    }

    /**
     * @return the txt6Y
     */
    public JTextField getTxt6Y() {
        return txt6Y;
    }

    /**
     * @return the txt5X
     */
    public JTextField getTxt5X() {
        return txt5X;
    }

    /**
     * @return the txt5Y
     */
    public JTextField getTxt5Y() {
        return txt5Y;
    }

    /**
     * @return the txt4X
     */
    public JTextField getTxt4X() {
        return txt4X;
    }

    /**
     * @return the txt4Y
     */
    public JTextField getTxt4Y() {
        return txt4Y;
    }

    /**
     * @return the txt3X
     */
    public JTextField getTxt3X() {
        return txt3X;
    }

    /**
     * @return the txt3Y
     */
    public JTextField getTxt3Y() {
        return txt3Y;
    }

    /**
     * @return the txt2X
     */
    public JTextField getTxt2X() {
        return txt2X;
    }

    /**
     * @return the txt2Y
     */
    public JTextField getTxt2Y() {
        return txt2Y;
    }

    /**
     * @return the lblError
     */
    public JLabel getLblError() {
        return lblError;
    }

    /**
     * @param lblError the lblError to set
     */
    public void setLblError(JLabel lblError) {
        this.lblError = lblError;
    }
}
